from importlib.resources import Resource
from apps.common.base.views import *
from apps.common.script.service import *
from apps.pay.financeForLessee.service import startFinanceHistory, startFinance
from apps.system.lessee.dao import LesseeDao
from apps.common.third.createImgCode import generate_captcha
from rest_framework import viewsets, status
from apps.pay.recordIncomes.functions import freeBalanceLockedRecord
from apps.pay.order.payReturnHandle.dismantleOrderByItem import dismantleOrderByItemHandle

class ScriptViewSet(BaseViewSet):
    authentication_classes = []
    permission_classes = []
    @action(methods=['post'], detail=False)
    def handle(self, request):
        params = getRequestParams(request)
        # try:
        #     handleSku()
        # except ValidationError as e:
        #     print('e', e)
        #     return Response(response_message(str(e)))
        
        # startFinanceHistory()
        # handleItem5()
        # generate_captcha()
        # handleItem4()
        # handleItem6()
        # for order in OrderDao().findAllSubOrder():
        #     if not order.expressageinfo:
        #         order.expressageinfo = order.order.expressageinfo
        #         order.save()
        dismantleOrderByItemHandle(OrderDao().findOneByOrderId('202504160920372235'))
        return Response(response_message('执行成功'))